package com.mini.res;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.mini.constant.CooManagerTypeEnum;
import com.mini.constant.CooOperationEnum;
import com.mini.constant.CooTabTypeEnum;
import com.mini.util.LongJsonDeserializer;
import com.mini.util.LongJsonSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.Date;

/**
 * 项目名称：traditional-business
 * 类 名 称：CooperativeShowRes
 * 类 描 述：TODO
 * 创建时间：2020/12/2 下午4:07
 * 创 建 人：zhanghuiying
 */
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("展示合作列表")
public class CooperativeShowRes {
    @JsonDeserialize(using = LongJsonDeserializer.class)
    @JsonSerialize(using = LongJsonSerializer.class)
    @ApiModelProperty(value = "合作id")
    private Long id;
    @ApiModelProperty(value = "合作类型（1-投放合作 销售发起  2-销售合作 投放发起）")
    private Integer cooperativeType;
    @ApiModelProperty(value = "投放人")
    private String throwUser;
    @ApiModelProperty(value = "投放人email")
    private String throwUserEmail;
    @ApiModelProperty(value = "投放工作室")
    private String throwRoom;
    @ApiModelProperty(value = "军团")
    private String armyGroup;
    @ApiModelProperty(value = "量子军团")
    private String quantumArmyGroup;
    @ApiModelProperty(value = "项目")
    private String project;
    @ApiModelProperty(value = "广告渠道")
    private String adChannel;
    @ApiModelProperty(value = "投放省份")
    private String throwProvince;
    @ApiModelProperty(value = "申请人")
    private String createUser;
    @ApiModelProperty(value = "申请人email")
    private String createUserEmail;
    @ApiModelProperty(value = "申请时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date createTime;
    @ApiModelProperty(value = "申请状态（0-全部 1-申请中 2-待处理 3-已确认 4-合作中 5-已撤销 6-已解除）")
    private Integer cooperativeState;
    @ApiModelProperty(value = "是否为最新")
    private Boolean newOne=false;

//    state:表中数据的状态（1-申请中／待处理 2-已确认／合作中 3-已撤销  4-已解除）
//    cooperativeType: 表中数据的类型 1-投放合作 销售发起 2-销售合作 投放发起
//    cooType:前端请求类型 1-投放合作管理 2-销售合作管理
//    listType:前端请求页面 1-申请列表 2-合作列表
    public void toCooperativeState(Integer state,Integer cooperativeType,Integer cooType,Integer listType){
        if (cooType.equals(cooperativeType) && state== CooOperationEnum.apply.getCode()) {
            this.cooperativeState=1;
            return;
        }
        if ( (!cooType.equals(cooperativeType)) && state==CooOperationEnum.apply.getCode()){
            this.cooperativeState=2;
            return;
        }
        if (listType == CooTabTypeEnum.applyList.getCode() && state==CooOperationEnum.confirm.getCode()){
            this.cooperativeState=3;
            return;
        }
        if (listType == CooTabTypeEnum.cooperativeList.getCode() && state==CooOperationEnum.confirm.getCode()){
            this.cooperativeState=4;
            return;
        }
        if (state==CooOperationEnum.undo.getCode()){
            this.cooperativeState=5;
            return;
        }
        if (state==CooOperationEnum.remove.getCode() && listType== CooTabTypeEnum.applyList.getCode()){
            this.cooperativeState=3;
            return;
        }
        if (state==CooOperationEnum.remove.getCode() && listType== CooTabTypeEnum.cooperativeList.getCode()){
            this.cooperativeState=6;
            return;
        }
    }

    public void toNewOne(Integer cooperativeType,Integer cooType){
        if (!cooperativeType.equals(cooType)){
            this.newOne=true;
        }
    }

}
